#include "CertificateRequirements.h"

CertificateRequirements::CertificateRequirements()
{
}

CertificateRequirements::~CertificateRequirements()
{
}

RequirementsGroup& CertificateRequirements::requirements(const RequirementType::Type i_type)
{
	return m_requirements[i_type];
}

int CertificateRequirements::completionPercentage()
{
	float totalRequirements = m_requirements[RequirementType::Priesthood].numberRequired() +
	m_requirements[RequirementType::Family].numberRequired() +
	m_requirements[RequirementType::Quorum].numberRequired() +
	m_requirements[RequirementType::Education].numberRequired() +
	m_requirements[RequirementType::Physical].numberRequired() +
	m_requirements[RequirementType::Spiritual].numberRequired() +
	m_requirements[RequirementType::Citizenship].numberRequired() +
	m_requirements[RequirementType::Service].numberRequired() +
	m_requirements[RequirementType::Journal].numberRequired();
	
	float completions = (float) 
		(m_requirements[RequirementType::Priesthood].completionPercentage() * m_requirements[RequirementType::Priesthood].numberRequired()+
		 m_requirements[RequirementType::Family].completionPercentage() * m_requirements[RequirementType::Family].numberRequired() +
		 m_requirements[RequirementType::Quorum].completionPercentage() * m_requirements[RequirementType::Quorum].numberRequired() +
		 m_requirements[RequirementType::Education].completionPercentage() * m_requirements[RequirementType::Education].numberRequired() +
		 m_requirements[RequirementType::Physical].completionPercentage() * m_requirements[RequirementType::Physical].numberRequired() +
		 m_requirements[RequirementType::Spiritual].completionPercentage() * m_requirements[RequirementType::Spiritual].numberRequired() +
		 m_requirements[RequirementType::Citizenship].completionPercentage() * m_requirements[RequirementType::Citizenship].numberRequired() +
         m_requirements[RequirementType::Service].completionPercentage() * m_requirements[RequirementType::Service].numberRequired() +
         m_requirements[RequirementType::Journal].completionPercentage() * m_requirements[RequirementType::Journal].numberRequired());
	      
    int complete =(int) (completions / totalRequirements);
    if (complete > 100)
    	complete = 100;
    
    return complete;
		
}
